<template>
  <div class="newsinfo-container">
    <h3 class="title">{{newsInfoList.title}}</h3>
    <p class="info">
    <span>发表时间：{{newsInfoList.add_time|dateFormat}}</span>
    <span>点击{{newsInfoList.click}}次</span>      
    </p>
    <hr>
    <div v-html="newsInfoList.content"></div>

    <comment :id="id"></comment>
  </div>
</template>

<script>
import comment from "../subcomponents/Comment.vue";

export default {
  data() {
    return {
      newsInfoList: {}
    };
  },
  created() {
    this.getNewsInfo();
  },
  methods: {
    async getNewsInfo() {
      const { data } = await this.$http.get("/api/getnew/" + this.id);
      if (data.status === 0) {
        this.newsInfoList = data.message[0];
      }
    }
  },
  props: ["id"],
  components: {
    comment
  }
};
</script>

<style lang="scss" scoped>
.newsinfo-container {
  padding: 3px;
  .title {
    font-size: 15px;
    color: red;
    text-align: center;
    line-height: 30px;
  }
  .info {
    display: flex;
    justify-content: space-between;
    color: #26a2ff;
    font-size: 13px;
  }
}
</style>

